// ******************************************************************
// * Copyright(c)  Steven Lu
// * Description   : Entity_PUR_PURCHASE_ORDER_ITEM_DETAIL
// * CreateDate    : 2011/10/25 11:27:58
// * Creater       : CodeSmith
// * LastChangeDate: 2011/10/25 11:27:58
// * LastChanger   : 2011/10/25 11:27:58
// * Version Info  : 1.0 For ESOL
// ******************************************************************

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Suzsoft.Smart.Data;
using ESOL.Common.Entity;

namespace ESOL.Business.Pur
{
/// <summary>
    /// PurPurchaseOrderItemDetail
    /// </summary>
    public partial class PurPurchaseOrderItemDetailBs
    {
        #region GetByID
        /// <summary>
        /// Get Entity
        /// </summary>
        /// <param name="objPurPurchaseOrderItemDetailEntity">Entity</param>
        /// <returns>Entity</returns>
        public static PurPurchaseOrderItemDetailEntity GetPurPurchaseOrderItemDetail(PurPurchaseOrderItemDetailEntity objPurPurchaseOrderItemDetailEntity)
        {
            return DataAccess.SelectSingle<PurPurchaseOrderItemDetailEntity>(objPurPurchaseOrderItemDetailEntity);
        }
        public static PurPurchaseOrderItemDetailEntity GetPurPurchaseOrderItemDetailById(string purItemId, string appItemId)
        {
            if (string.IsNullOrEmpty(purItemId) || string.IsNullOrEmpty(appItemId))
            {
                return null;
            }
            PurPurchaseOrderItemDetailEntity entity = new PurPurchaseOrderItemDetailEntity();
            entity.PurchaseItemId = purItemId;
            entity.ApplicationItemId = appItemId;
            return DataAccess.SelectSingle<PurPurchaseOrderItemDetailEntity>(entity);
        }
        public static PurPurchaseOrderItemDetailEntity GetPurPurchaseOrderItemDetailByAppItemId(string appItemId)
        {
            if (string.IsNullOrEmpty(appItemId))
            {
                return null;
            }
            PurPurchaseOrderItemDetailEntity entity = new PurPurchaseOrderItemDetailEntity();
            entity.ApplicationItemId = appItemId;
            return DataAccess.SelectSingle<PurPurchaseOrderItemDetailEntity>(entity);
        }
        public static List<PurPurchaseOrderItemDetailEntity> GetPurPurchaseOrderItemDetailByPurItemId(string purItemId)
        {
            PurPurchaseOrderItemDetailEntity entity = new PurPurchaseOrderItemDetailEntity();
            entity.PurchaseItemId = purItemId;
            return DataAccess.Select<PurPurchaseOrderItemDetailEntity>(entity);
        }
        public static List<PurPurchaseOrderItemDetailEntity> GetPurPurchaseOrderItemDetailByPurOrderId(string purOrderId)
        {
            string sql = @"SELECT POID.*
                            FROM PUR_PURCHASE_ORDER_ITEM_DETAIL POID
                            INNER JOIN PUR_PURCHASE_ORDER_ITEM POI ON POI.PURCHASE_ITEM_ID = POID.PURCHASE_ITEM_ID
                            WHERE POI.PURCHASE_ORDER_ID = '" + purOrderId + "'";
            return DataAccess.Select<PurPurchaseOrderItemDetailEntity>(sql);
        }
        #endregion

        #region Insert
        /// <summary>
        /// Insert Data
        /// </summary>
        /// <param name="objPurPurchaseOrderItemDetailEntity">Entity</param>
        /// <returns>true Insert Succeed; false Insert Fail</returns>
        public static bool InsertPurPurchaseOrderItemDetail(PurPurchaseOrderItemDetailEntity objPurPurchaseOrderItemDetailEntity)
        {
            return DataAccess.Insert(objPurPurchaseOrderItemDetailEntity);
        }

        public static bool InsertPurPurchaseOrderItemDetail(List<PurPurchaseOrderItemDetailEntity> objPurPurchaseOrderItemDetailEntityList)
        {
            return DataAccess.Insert(objPurPurchaseOrderItemDetailEntityList);
        }
        #endregion

        #region Update
        /// <summary>
        /// Update Data
        /// </summary>
        /// <param name="objPurPurchaseOrderItemDetailEntity">Entity</param>
        /// <returns>true Update Succeed; false Update Fail</returns>
        public static bool UpdatePurPurchaseOrderItemDetail(PurPurchaseOrderItemDetailEntity objPurPurchaseOrderItemDetailEntity)
        {
            return DataAccess.Update(objPurPurchaseOrderItemDetailEntity);
        }

        public static bool UpdatePurPurchaseOrderItemDetail(List<PurPurchaseOrderItemDetailEntity> objPurPurchaseOrderItemDetailEntityList)
        {
            return DataAccess.Update<PurPurchaseOrderItemDetailEntity>(objPurPurchaseOrderItemDetailEntityList);
        }
        #endregion

        #region Delete
        /// <summary>
        /// Delete Data
        /// </summary>
        /// <param name="objPurPurchaseOrderItemDetailEntity">Entity</param>
        /// <returns>true Delete Succeed; false Delete Fail</returns>
        public static bool DeletePurPurchaseOrderItemDetail(PurPurchaseOrderItemDetailEntity objPurPurchaseOrderItemDetailEntity)
        {
            return DataAccess.Delete(objPurPurchaseOrderItemDetailEntity);
        }

        public static bool DeletePurPurchaseOrderItemDetail(List<PurPurchaseOrderItemDetailEntity> objPurPurchaseOrderItemDetailEntityList)
        {
            return DataAccess.Delete<PurPurchaseOrderItemDetailEntity>(objPurPurchaseOrderItemDetailEntityList);
        }
        #endregion

        #region GetAll
        /// <summary>
        /// Get All Data
        /// </summary>
        /// <returns>Back All Data<returns>
        public static DataSet GetPurPurchaseOrderItemDetailAll()
        {
            return DataAccess.SelectAllDataSet<PurPurchaseOrderItemDetailEntity>();
        }
        /// <summary>
        /// Get All Data List
        /// </summary>
        /// <returns>Back All Data List<returns>
        public static List<PurPurchaseOrderItemDetailEntity> GetPurPurchaseOrderItemDetailAllList()
        {
            return DataAccess.SelectAll<PurPurchaseOrderItemDetailEntity>();
        }
        #endregion
	}
	
	
}	

